#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QHostAddress>
#include <QNetworkInterface>
#include <QHostInfo>
#include "src/NetHelper.h"


MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::updateUI()
{
    ui->label_IP->setText(localIP);
    ui->label_computerName->setText(computerName);
    ui->label_MAC->setText(MAC);
    ui->label_publicIP->setText(publicIP);
}


void MainWindow::on_pushButton_clicked()
{
    QHostAddress IPV4 = getHostIPV4Address();
    quint32 ip = IPV4.toIPv4Address();

    localIP = IPV4IntegerToString(ip);
    computerName = get_localmachine_name();

    MAC = get_localmachine_mac();
    publicIP = GetNetIP(GetHtml("http://whois.pconline.com.cn/"));
    updateUI();
}

void MainWindow::on_print_clicked()
{
    outPutContentMacInfo();
}
